<?php

namespace backend\controllers;

use common\cache\DictCache;
use common\models\service\WithdrawalService;
use common\models\System;
use common\models\Withdrawal;
use Yii;

class WithdrawalController extends BaseController
{
    public function init()
    {
        parent::init();
        $this->model = Withdrawal::className();
    }

    /**
     * 列表
     * @return array|string
     */
    public function actionIndex()
    {
        if (Yii::$app->request->isPost){
            $post = Yii::$app->request->post();
            $fund_type = $post['fund_type']??'';
            if ((int)$fund_type==3){
                $campus_id = $this->campus_id ??'';
            }
            return WithdrawalService::backList($fund_type,$campus_id);
        }
        $review_status = DictCache::get('review_status');
        Yii::$app->view->params['review_status'] = $review_status;
        return parent::actionIndex();
    }

    /**
     * 审核
     * @return array|bool|string
     */
    public function actionReview()
    {
        if (Yii::$app->request->isPost){
            $post = Yii::$app->request->post();
            return WithdrawalService::review($post);
        }
        $data = WithdrawalService::review([]);
        return $this->render('',$data);
    }

    public function actionSet()
    {
        if (Yii::$app->request->isPost){

        }
        $model = System::getModel();
        $withdraw_way = DictCache::get('withdraw_way');
        $model->withdraw_way = explode(',',$model->withdraw_way);
        return $this->render('',['model'=>$model,'withdraw_way'=>$withdraw_way]);
    }
}